package cate.game.role.mail;

import cp.solution.business.game.component.NoticeParam;
import cate.game.res.MixRes;
import cate.game.util.GameKit;
import easy.java.dev.note.NoteField;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;

@Getter
@Setter
public class Mail {

    public static final byte TYPE_DEFAULT = 0;
    public static final byte TYPE_GM = 1;

    @NoteField(value = "唯一id")
    public String uid;

    @NoteField(value = "邮件类型", detail = "默认为0")
    public byte type;

    @NoteField(value = "邮件标题")
    public String title;

    @NoteField(value = "邮件内容ID")
    public int contentId;

    @NoteField(value = "邮件内容参数")
    public List<Object> paramList;

    @NoteField(value = "奖励")
    public MixRes reward;

    @NoteField(value = "创建时间")
    public long createTime;

    @NoteField(value = "是否已读")
    public boolean read;

    @NoteField(value = "是否已领奖励")
    public boolean got;

    @NoteField(value = "因为什么操作得到该邮件")
    public int operation;

    @NoteField(value = "操作子类型")
    public int operationSub;

    public Mail(){
        this.uid = GameKit.uid();
    }

    /** 直接设置为完全的文本内容 */
    public void setContent(String content) {
        this.contentId = 0;
        this.paramList = new ArrayList<>();
        this.paramList.add(new NoticeParam(content));
    }

    public Mail copy() {
        Mail cp = new Mail();
        cp.uid = this.uid;
        cp.type = this.type;
        cp.title = this.title;
        cp.contentId = this.contentId;
        cp.paramList = this.paramList;
        if (this.reward != null) {
            cp.reward = this.reward.copy();
        }
        cp.createTime = this.createTime;
        cp.read = this.read;
        cp.got = this.got;
        cp.operation = this.operation;
        cp.operationSub = this.operationSub;
        return cp;
    }
}
